<?php

namespace app\common\validate\tyyh;

class UserWalletBalanceOrderPay extends Base
{
	/**
     * 验证规则
     */
    protected $rule = [
        'lock'                => 'require',
        'id'                  => 'require'
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'lock.require'                  => '验证规则场景不存在',
        'id.require'                    => '退款单ID不能为空',
        'id.isUser'                     => '退款单不属于您',
        'id.isCurrentPay'               => '退款单已经完成，无法取消'

    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'balance_order_pay' => ['uid', 'id' => 'require|isUser:tyyh\\UserWalletBalanceOrder|isCurrentPay']
    ];

    //验证订单当前是否可以支付
    protected function isCurrentPay($value, $rule, $data = []) {
        $order = loader()->loadAny('only', 'tyyh\\UserWalletBalanceOrder')->get_row($data['id']);
        return $order->status == loadEnum('UserWalletBalanceOrderStatus')->code2key('daizhifu');
    }
}
